package org.fullhappy.library.service;

import java.util.ArrayList;
import java.util.List;

import javax.faces.model.SelectItem;

import org.fullhappy.entity.EbookFormat;
import org.fullhappy.library.dao.EbookFormatDAO;


public class EbookService {
	    EbookFormatDAO ebookFormatDao = new EbookFormatDAO();

	   

	    public List<SelectItem> getListSelectFormatItems() {
	        List<SelectItem> selectFormatItems = new ArrayList<SelectItem>();
	        List<EbookFormat> formats = ebookFormatDao.findAll();
	        for (EbookFormat ebookFormat : formats) {
	            selectFormatItems.add(new SelectItem(ebookFormat.getFormatId(), ebookFormat.getTitle()));
	        }
	        return selectFormatItems;
	    }

	    public EbookFormat create(EbookFormat ebookFormat) throws Exception {
	        return ebookFormatDao.create(ebookFormat);
	    }
}
